package hashMap2;

import java.util.*;

public class HashMapDemo {

	public static void main(String[] args) {
		Map<String, Students> students = new HashMap<String, Students>();
		Students student1 = new Students("张三", "男");
		Students student2 = new Students("李四", "女");
		Students student3 = new Students("王五", "男");

		students.put("Tim", student1);
		students.put("Federer", student2);
		students.put("Rafa", student3);

		// 获得键的集合
		Set<String> keys = students.keySet();
		// 用iterator迭代器拿到所有的键
		Iterator<String> it = keys.iterator();
		while (it.hasNext()) {
			// 获得键
			String key = it.next();
			// 获得键对应的值
			Students value = students.get(key);
			// 输出学员信息
			System.out.println(key + "对应的学员姓名是:" + value.getName() + "; 性别是:" + value.getGender());
		}

	}

}
